/**
 * 
 */
package com.duck.base;

import java.util.HashMap;


/**
 * @author Richard Rodriguez
 * 18/9/2014
 */
public abstract class Duck {

    private HashMap<String,Behavior> behaviors;
    public abstract void display();
    
    
    public Duck() {
	super();
	behaviors = new HashMap<String,Behavior>();
    }

    
    public void addBehavior(Behavior behavior){
	if(!behaviors.containsKey(behavior))
	    behaviors.put(behavior.getBehaviorType(),behavior);
    }

    public void removeBehavior(String behavior){
	if(behaviors.containsKey(behavior))
	    behaviors.remove(behavior);
    }
    
    public void changeBehavior(String behaviorType, Behavior behavior){
	if(behaviors.containsKey(behaviorType)){
	    removeBehavior(behaviorType);
	    addBehavior(behavior);
	}
    }
    
    
    public void performBehavior(String behaviorType){
	Behavior behavior = behaviors.get(behaviorType);
	behavior.runBehavior();
    }
    
    
    
}
